<template>
  <span class="qc-link" @click="handleClick">
    <slot></slot>
  </span>
</template>
<script lang='ts'>
import { defineComponent } from "vue";
import { useRouter } from "vue-router";
export default defineComponent({
  name: "Link",
  props: {
    url: {
      type: String,
      required: true,
    },
    //参数
    query: {
      type: Object,
      default: () => {
        return {};
      },
    },
    params: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  emits: ["handlerClick"],
  setup(props) {
    const router = useRouter();
    const handleClick = () => {
      router.push({
        path: props.url,
        query: props.query,
        params: props.params,
      });
    };
    return {
      handleClick,
    };
  },
});
</script>